﻿@model IEnumerable<MyWebApp.Models.MenuItem>

<aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
        <!-- sidebar menu: : style can be found in sidebar.less -->
        <ul class="sidebar-menu">
            <!--标签-->
            <li class="header">主菜单</li>
            @{
                foreach (var parentItem in Model.Where(p => p.ParentID == "0"))
                {
                    <li class="treeview">
                        <a href="#">
                            <i class="fa @parentItem.Icon"></i>
                            <span>@parentItem.Name</span>
                            <span class="pull-right-container">
                                <i class="fa fa-angle-left pull-right"></i>
                            </span>
                        </a>
                        <ul class="treeview-menu">
                            @{
                                foreach (var item2 in Model.Where(p => p.ParentID == parentItem.Id))
                                {
                                    var childItems = Model.Where(p => p.ParentID == item2.Id);  //level3
                                    bool haveChilds = childItems.Count() > 0;
                                    if (haveChilds)
                                    {
                                        <li>
                                            <a href="#">
                                                <i class="fa @item2.Icon">@item2.Name</i>
                                                <span class="pull-right-container">
                                                    <i class="fa fa-angle-left pull-right"></i>
                                                </span>
                                            </a>
                                            <ul class="treeview-menu">
                                                @foreach (var item3 in childItems)
                                                {
                                                    <li data-url="@item3.Url">
                                                        <a>
                                                            @*href="@item3.Url"*@
                                                            <i class="fa @item3.Icon">@item3.Name</i>
                                                        </a>
                                                    </li>
                                                }
                                            </ul>
                                        </li>
                                    }
                                    else
                                    {
                                        <li data-url="@item2.Url">
                                            <a>
                                                @*href="@item2.Url"*@
                                                <i class="fa @item2.Icon">@item2.Name</i>
                                            </a>
                                        </li>
                                    }
                                }
                            }
                        </ul>
                    </li>
                                }
            }
            @*<li class="header">LABELS</li>
            <li><a href="#"><i class="fa fa-circle-o text-red"></i> <span>Important</span></a></li>
            <li><a href="#"><i class="fa fa-circle-o text-yellow"></i> <span>Warning</span></a></li>
            <li><a href="#"><i class="fa fa-circle-o text-aqua"></i> <span>Information</span></a></li>*@
        </ul>
    </section>
    <!-- /.sidebar -->
</aside>